Imports System
Imports System.Collections
Imports ribs.DataAccessLayer

Namespace BusinessLogicLayer

    Public Class ActionCollection
        Inherits CollectionBase

        Public Enum ActionFields
            ActionID
            EntryDate
            RibsID
            Action
            ContactMethod
            Note
            User
            ActionDate
            RibsState
            Reason
        End Enum

        

        'Public Sub Sort(ByVal sortField As ProjectFields, ByVal isAscending As Boolean)
        '    Select Case sortField
        '        Case ProjectFields.Name
        '            InnerList.Sort(New NameComparer())
        '        Case ProjectFields.Manager
        '            InnerList.Sort(New ManagerComparer())
        '        Case ProjectFields.Creator
        '            InnerList.Sort(New CreatorComparer())
        '        Case ProjectFields.DateCreated
        '            InnerList.Sort(New CreatedComparer())
        '    End Select
        '    If Not isAscending Then
        '        InnerList.Reverse()
        '    End If
        'End Sub 'Sort


        'Private NotInheritable Class NameComparer
        '    Implements IComparer

        '    Public Function [Compare](ByVal x As Object, ByVal y As Object) As Integer Implements IComparer.Compare
        '        Dim first As Project = CType(x, Project)
        '        Dim second As Project = CType(y, Project)
        '        Return first.Name.CompareTo(second.Name)
        '    End Function 'Compare
        'End Class 'NameComparer



        'Private NotInheritable Class ManagerComparer
        '    Implements IComparer

        '    Public Function [Compare](ByVal x As Object, ByVal y As Object) As Integer Implements IComparer.Compare
        '        Dim first As Project = CType(x, Project)
        '        Dim second As Project = CType(y, Project)
        '        Return first.ManagerDisplayName.CompareTo(second.ManagerDisplayName)
        '    End Function 'Compare
        'End Class 'ManagerComparer



        'Private NotInheritable Class CreatorComparer
        '    Implements IComparer

        '    Public Function [Compare](ByVal x As Object, ByVal y As Object) As Integer Implements IComparer.Compare
        '        Dim first As Project = CType(x, Project)
        '        Dim second As Project = CType(y, Project)
        '        Return first.CreatorDisplayName.CompareTo(second.CreatorDisplayName)
        '    End Function 'Compare
        'End Class 'CreatorComparer


        'Private NotInheritable Class CreatedComparer
        '    Implements IComparer

        '    Public Function [Compare](ByVal x As Object, ByVal y As Object) As Integer Implements IComparer.Compare
        '        Dim first As Issue = CType(x, Issue)
        '        Dim second As Issue = CType(y, Issue)
        '        Return first.DateCreated.CompareTo(second.DateCreated)
        '    End Function 'Compare
        'End Class 'CreatedComparer

        Default Public Property Item(ByVal index As Integer) As Action
            Get
                Return CType(List(index), Action)
            End Get
            Set(ByVal value As Action)
                List(index) = value
            End Set
        End Property

        Public Function Add(ByVal value As Action) As Integer
            Return List.Add(value)
        End Function 'Add


        Public Function IndexOf(ByVal value As Action) As Integer
            Return List.IndexOf(value)
        End Function 'IndexOf


        Public Sub Insert(ByVal index As Integer, ByVal value As Action)
            List.Insert(index, value)
        End Sub 'Insert


        Public Sub Remove(ByVal value As Action)
            List.Remove(value)
        End Sub 'Remove


        Public Function Contains(ByVal value As Action) As Boolean
            ' If value is not of type Project, this will return false.
            Return List.Contains(value)
        End Function 'Contains


        Protected Overrides Sub OnInsert(ByVal index As Integer, ByVal value As Object)
            If Not value.GetType() Is Type.GetType("ribs.BusinessLogicLayer.Action") Then
                Throw New ArgumentException("value must be of type Action.", "value")
            End If
        End Sub 'OnInsert

        Protected Overrides Sub OnRemove(ByVal index As Integer, ByVal value As Object)
            If Not value.GetType() Is Type.GetType("ribs.BusinessLogicLayer.Action") Then
                Throw New ArgumentException("value must be of type Action.", "value")
            End If
        End Sub 'OnRemove

        Protected Overrides Sub OnSet(ByVal index As Integer, ByVal oldValue As Object, ByVal newValue As Object)
            If Not newValue.GetType() Is Type.GetType("ribs.BusinessLogicLayer.Action") Then
                Throw New ArgumentException("newValue must be of type Action.", "newValue")
            End If
        End Sub 'OnSet

        Protected Overrides Sub OnValidate(ByVal value As Object)
            If Not value.GetType() Is Type.GetType("ribs.BusinessLogicLayer.Action") Then
                Throw New ArgumentException("value must be of type Action.")
            End If
        End Sub 'OnValidate

    End Class

End Namespace




